package daos;

import java.util.List;

import entidades.Aluno;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import Facade.AcademicoFacade;

public class AlunoDao implements AcademicoFacade<Aluno> {
	static EntityManagerFactory factory = Persistence
			.createEntityManagerFactory("academicoDatabase");

	public Aluno salvar(Aluno aluno) {
		EntityManager manager = factory.createEntityManager();
		manager.persist(aluno);
		manager.getTransaction().begin();
		manager.getTransaction().commit();
		manager.close();
		return aluno;

	}

	public void Excluir(Aluno aluno) {
		EntityManager manager = factory.createEntityManager();
		manager.remove(aluno);
		manager.getTransaction().begin();
		manager.getTransaction().commit();
		manager.close();

	}

	@Override
	public Aluno atualizar(Aluno objeto) {
		// TODO Auto-generated method stub
		return null;
	}

	public Aluno buscarPorId(Class<Aluno> aluno, Long idusuario) {
		EntityManager manager = factory.createEntityManager();
		return manager.find(Aluno.class, idusuario);

	}

	@Override
	public List<Aluno> buscarTodos(Class<Aluno> objeto) {
		// TODO Auto-generated method stub
		return null;
	}

}
